-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: keystore decoding #703
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
||
const { kdfparams } = keystore.crypto; | ||
|
||
// Derive key using PBKDF2 similar to SwapKit's `pbkdf2Async` call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Derive key using PBKDF2 similar to SwapKit's `pbkdf2Async` call | ||
const passwordKey = await ( | ||
await crypto | ||
).subtle.importKey("raw", encoder.encode(password), "PBKDF2", false, ["deriveBits"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async loadFromKeystore(stringifiedKeystore: string, password: string) { | ||
const keystore = JSON.parse(stringifiedKeystore); | ||
const mnemonic = await decryptFromKeystore(keystore, password); | ||
this.set("#mnemonic", mnemonic); | ||
return this; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks unused, but actually adds loadsFromKeystore
to Vault
class for clients' consumption e.g:
https://github.com/shapeshift/web/pull/8442/files#diff-cb441bd026f8d983d9243fba41e8f70444867e130f150f1b25a22de360dd0008R51
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placeholder comment - as usual, don't forget to bump hdwallet versions with lerna before merging me
Description
This adds Keystore decoding support, following Swapkit's (https://github.com/thorswap/SwapKit/blob/349a9212d8357cc35a8bab771728bbc8d6900ebc/packages/wallets/keystore/src/helpers.ts) logic.
Note, logic has been redeclared here, as SwapKit build is all sorts of broken re: transitive dependencies and I couldn't get it to work after way too many tries.
Issue
Testing
Screenshots